package com.koocloud.electroplatemanage.pojo;

import java.util.Comparator;
import java.util.List;

public class Permission {

  private long id; //权限记录id
  private String permissionName;//权限名称
  private String url;//权限地址
  private String icon;//权限图片
  private int order; //菜单顺序
  private long parentId;//父权限id  如果是子菜单，则记录其父菜单的id,否则 没有就为-1记录
  private long lvl;//第几层权限，第一层为1，以此类推 
  private long type;//用来区分菜单还是按钮（0.菜单1.按钮）
  private List<Permission> children;
  private String permissionCode;//权限编码

	public Permission() {
		super();
	}

	public Permission(long id, String permissionName, String url, String icon, int order, long parentId, long lvl,
					  long type, List<Permission> children, String permissionCode) {
		this.id = id;
		this.permissionName = permissionName;
		this.url = url;
		this.icon = icon;
		this.order = order;
		this.parentId = parentId;
		this.lvl = lvl;
		this.type = type;
		this.children = children;
		this.permissionCode = permissionCode;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getPermissionName() {
		return permissionName;
	}

	public void setPermissionName(String permissionName) {
		this.permissionName = permissionName;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public long getParentId() {
		return parentId;
	}

	public void setParentId(long parentId) {
		this.parentId = parentId;
	}

	public long getLvl() {
		return lvl;
	}

	public void setLvl(long lvl) {
		this.lvl = lvl;
	}

	public long getType() {
		return type;
	}

	public void setType(long type) {
		this.type = type;
	}

	public List<Permission> getChildren() {
		return children;
	}

	public void setChildren(List<Permission> children) {
		this.children = children;
	}

	public String getPermissionCode() {
		return permissionCode;
	}

	public void setPermissionCode(String permissionCode) {
		this.permissionCode = permissionCode;
	}


	@Override
	public String toString() {
		return "Permission{" +
				"id=" + id +
				", permissionName='" + permissionName + '\'' +
				", url='" + url + '\'' +
				", icon='" + icon + '\'' +
				", order=" + order +
				", parentId=" + parentId +
				", lvl=" + lvl +
				", type=" + type +
				", children=" + children +
				", permissionCode='" + permissionCode + '\'' +
				'}';
	}

	/*
	 * 排序,根据order排序
	 */
  public static Comparator<Permission> order(){
    Comparator<Permission> comparator = new Comparator<Permission>() {
	@Override
	public int compare(Permission o1, Permission o2) {
        if(o1.getOrder() != o2.getOrder()){
            return o1.getOrder() - o2.getOrder();
          }
          return 0;
	}
    };
    return comparator;
  }
  
  
  
  

}
